package com.jams.goodox.utils;

import android.content.Context;

import com.jams.goodox.R;
import com.jams.goodox.entity.Product;

/**
 * Created by jams on 2016/8/24.
 * ***
 * Tel: ***
 *
 * 商品提示，判断工具类，适用于商圈
 */

public class ProductUtils {
    //判断是否可以购买
    public static boolean isCanBuy(Context context, Product info, int count) {
        int temp = count;
        if (temp >= info.getProductStock()) {
            ToastUtil.show(context, context.getResources().getString(R.string.can_stock_top));
            return false;
        }
        if (info.getProductLimitBuy() == -1) {
            ToastUtil.show(context, context.getResources().getString(R.string.can_not_buy));
            return false;
        }
        if (info.getProductLimitBuy() != 0 && temp >= info.getProductLimitBuy()) {
            ToastUtil.show(context, context.getResources().getString(R.string.can_buy_top));
            return false;
        }
        if (temp >= 999) {
            ToastUtil.show(context, context.getResources().getString(R.string.can_buy_top));
            return false;
        }
        return true;
    }
}
